<?php
namespace app\admin\controller\v1;

use app\common\model\Article as ArticleModel;
use app\admin\validate\CreateAdminRole;
use app\admin\validate\CreateArticle;
use app\common\model\AdminRole as AdminRoleModel;
use app\common\model\Admin as AdminModel;


class Article extends BaseController
{
    public function createOne(){
        $validate = new CreateArticle();
        //验证
        $validate->goCheck();
        $data = $validate->request->post();
        ArticleModel::createOne($data);
        return successReturn();
    }
    public function getAll()
    {
        $articles = ArticleModel::getAll();
        return successReturn($articles);
    }
    public function getById($id)
    {
        $admin = ArticleModel::getById($id);
        return successReturn($admin);
    }
    public function deleteOne($id){
        ArticleModel::deleteOne($id);
        return successReturn();
    }

    public function updateOne($id){
        $data = input('put.');
        ArticleModel::updateOne($id,$data);
        return successReturn();
    }
}
